function customizeGlImpact(transactionRecord, standardLines, customLines, book) {
    try {
        //生产成本 AccountId：1345
        //生产成本 -直接材料 AccountId：859
        //将工序号1,2,3,4转化成A,B,C,D
        var operationNumber = transactionRecord.getFieldText('startoperation');
        var operationCharCode = String.fromCharCode(64 + parseInt(operationNumber));
        //将工序号identify1,2,3,4转化成A,B,C,D
        var identify = transactionRecord.getFieldValue('custbody_identify');
        var identifyCharCode = String.fromCharCode(64 + parseInt(identify));
        var issueCode = 'X' + operationCharCode + identifyCharCode;
        var customerGLImpactAmount = '';
        var itemAccountIds = [];
        //获得所有item的
        for (var i = 0; i < transactionRecord.getLineItemCount('component'); i++) {
            var itemId = transactionRecord.getLineItemValue('component', 'item', (i + 1));//getLineItemValue   从1开始
            if (itemId !== '868' && itemId !== '49' && itemId !== '866') {
                var rec = nlapiLoadRecord('inventoryitem', itemId);
                var itemAccountId = parseInt(rec.getFieldValue('assetaccount'));
                itemAccountIds.push(itemAccountId);
            }
        }
        //nlapiLogExecution('DEBUG', 'itemAccountIds', JSON.stringify(itemAccountIds));
        var amount;
        for (var i = 0; i < standardLines.getCount(); i++) {
            var currLine = standardLines.getLine(i);
            var accountId = currLine.getAccountId();
            for (var j = 0; j < itemAccountIds.length; j++) {
                if (accountId === itemAccountIds[j]) {
                    amount = currLine.getCreditAmount();
                    // nlapiLogExecution('DEBUG', 'itemAccountId', JSON.stringify(itemAccountIds[j]));
                    if (amount > 0) {
                        addDebitCustomLines(customLines, amount, accountId, "冲销借方 原材料");
                        // 借：生产成本：生产成本-直接材料 贷：原材料【即对应货品上的资产科目】；
                        // 借：生产成本  贷：生产成本：生产成本-直接材料；
                        addDebitCustomLines(customLines, amount, 859, "产生借方 生产成本：生产成本-直接材料");
                        addCreditCustomLines(customLines, amount, accountId, "产生贷方 原材料");
                        addDebitCustomLines(customLines, amount, 1345, "产生借方 生产成本");
                        addCreditCustomLines(customLines, amount, 859, "产生贷方 生产成本：生产成本-直接材料");

                        customerGLImpactAmount += amount + ':';
                    }
                }
            }
            if (accountId === 1345) {
                amount = currLine.getDebitAmount();
                if (amount > 0) {
                    addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");
                }
            }
        }

        var woId = transactionRecord.getFieldValue('createdfrom');
        var woRec = nlapiLoadRecord('workorder', woId);
        var oldGLImpact = woRec.getFieldValue('custbody_gl_impact_record');
        if (oldGLImpact == null) {
            oldGLImpact = '';
        }
        //如果有Id,则是编辑状态,编辑后要  对原先的总账进行更新
        if (transactionRecord.getId()) {
            var strArray = oldGLImpact.split('|');
            for (var index in strArray) {
                if (strArray[index].indexOf(issueCode) !== -1) {
                    strArray[index] = issueCode + customerGLImpactAmount;
                }
            }
            var newGLImpact = strArray.join('|');
            woRec.setFieldValue('custbody_gl_impact_record', newGLImpact);
        }
        //如果没有,则是创建状态  ,  创建直接添加
        else {
            var customerGLImpact = issueCode + customerGLImpactAmount + '|';
            woRec.setFieldValue('custbody_gl_impact_record', oldGLImpact + customerGLImpact);
        }
        nlapiSubmitRecord(woRec, true);
    } catch (e) {
        nlapiLogExecution('DEBUG', 'e', JSON.stringify(e));
    }
}

